﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GP.Logic;
using GP.Logic.Model;

namespace WebForms.Doctor
{
    public partial class Patient : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DoctorService doc = new DoctorService();
                Citizen currentCitizen = doc.GetCitizen();

                if (currentCitizen == null)
                {
                    Response.Redirect("/Doctor/", true);
                    return;
                }

                gvEvents.DataSource = currentCitizen.Events;
                gvEvents.DataBind();

                GP.Logic.Model.Doctor doctor = doc.GetDoctor();

                grantaccessBut.Visible = currentCitizen.DocId == doctor.DocId;
                // CitizenIDValue.Text = currentCitizen.CitizenId.ToString();

                
                DocNameValue.Text = doctor.Name;

                primaryDoctor.Text = currentCitizen.Doctor.Name;
                SocialSecurityValue.Text = currentCitizen.SocialSecurity.ToString();
                NameValue.Text = currentCitizen.Name.ToString();
                TimeCreatedValue.Text = currentCitizen.TimeCreated.ToString();
                PhoneValue.Text = currentCitizen.Phone.ToString();
                EmailValue.Text = currentCitizen.Email.ToString();
                PassKeyValue.Text = currentCitizen.PassKey.ToString();

            }
        }

        protected void grantaccessBut_Click(object sender, EventArgs e)
        {
            Response.Redirect("/Doctor/GrantAccess.aspx?CitizenID="+Request["citizenID"]);
        }
    }
}